<!-- 处理按钮组 -->

<template>
  <el-dropdown placement="bottom-start" :disabled="!inited" @command="openDeal">
    <BtnPrimary><span>批量处理</span> <i class="el-icon-arrow-down" /></BtnPrimary>

    <template #dropdown>
      <el-dropdown-menu>
        <el-dropdown-item v-for="[id, name] in btnDict" :key="id" :command="id">{{ name }}</el-dropdown-item>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import AlarmFooter from '@admin/components/detail/DetailAlarm/AlarmFooter'

// ============================== 导出组件 ============================== //

export default {
  /**
   * 名称定义 (实际使用名称)
   */
  name: 'BtnsDeal',

  /**
   * 混入列表 (配置选项合并)
   */
  mixins: [CORE.mixWeb(), CORE.mixModal('deal', 'deal_')],

  /**
   * 计算属性 (慎用箭头函数)
   */
  computed: AlarmFooter.computed,

  /**
   * 本地方法 (轻量重要在前)
   */
  methods: {
    /**
     * 打开处理弹窗
     */
    openDeal(type) {
      const { param: { idList: ids }, total } = this
      const idNum = ids.length || total
      const dealAll = !ids.length
      const [id, operate] = CORE.DICT.ALARM_DEAL_TYPE.find(([id]) => id === type) || []
      this.deal_openEdit({ ids, idNum, dealAll, dealType: +id, operate: `批量${operate}` })
    },
  },
}
</script>
